#!/usr/bin/env python 
# -*- coding:utf-8 -*-

import mysql.connector
import random
db_connect = mysql.connector.connect(
    host='8.142.105.62',
    user='root',
    passwd='123456',
    database='test',
    charset='utf8'
)
db = db_connect.cursor()
sql = "insert into user(phone,idcard) value(%s,%s)"

num = random.randint(10000000,99999999)
year = random.randint(1949,2022)
month = random.randint(10,12)
day = random.randint(10,20)
end_num = random.randint(1000,3000)
idcard = '410426'+str(year)+str(month)+str(day)+str(end_num)
phone = '176'+str(num)

val = (phone,idcard)
db.execute(sql,val)
db_connect.commit()
id = db.getlastrowid()
print("插入数据成功ID:",id)







